<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
   
  <meta name="keywords" content="Java Python" />
   
  <meta name="description" content="From Zero to Hero" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    操作系统-01-概述 |  朱酱酱的学习博客
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/css/style.css">

  
<script src="/js/pace.min.js"></script>


  

  

<link rel="alternate" href="/atom.xml" title="朱酱酱的学习博客" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      <section class="outer">
  <article id="post-Linux/操作系统-01-概述" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  操作系统-01-概述
</h1>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/10/03/Linux/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F-01-%E6%A6%82%E8%BF%B0/" class="article-date">
  <time datetime="2020-10-03T04:00:53.000Z" itemprop="datePublished">2020-10-03</time>
</a>
      
      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">2.1k字</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">7分钟</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h1 id="操作系统-01-概述"><a href="#操作系统-01-概述" class="headerlink" title="操作系统-01-概述"></a>操作系统-01-概述</h1><h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><ul>
<li>是系统最基本最核心的软件，属于系统软件</li>
<li>控制和管理整个计算机的硬件和软件资源</li>
<li>合理的组织、调度计算机的工作与资源的分配</li>
<li>为用户和其它软件提供方便的接口和环境</li>
</ul>
<p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/103437449.png" alt="mark"></p>
<a id="more"></a>

<h2 id="1-基本特征"><a href="#1-基本特征" class="headerlink" title="1. 基本特征"></a>1. 基本特征</h2><ol>
<li><strong>并发</strong></li>
</ol>
<ul>
<li><code>并发</code>：两个或多个事件在同一<code>时间间隔内</code>发生，这些事件在宏观上是同时发生的，在微观上是交替发生的， 操作系统的并发性指系统中同时存在着多个运行的程序</li>
<li><code>并行</code>：两个或多个事件在同一<code>时刻</code>发生</li>
<li>一个单核(CPU)同一时刻只能执行一个程序，因此操作系统会协调多个程序使他们交替进行（这些程序在宏观上是同时发生的，在微观上是交替进行的）</li>
</ul>
<ol start="2">
<li><strong>共享</strong></li>
</ol>
<ul>
<li>互斥共享<br>同一个时间段只允许一个进程访问资源(摄像头/麦克风)</li>
<li>同时共享<br>允许一个时间段多个进程“同时”(宏观上)访问某些资源（微观上是分时共享），比如硬盘读写</li>
</ul>
<ol start="3">
<li><strong>虚拟</strong></li>
</ol>
<ul>
<li>虚拟是指把一个物理上的实体变为若干个逻辑上的对应物。物理实体(前者)是实际存在的,而逻辑上对应物(后者)是用户感受到的。<ul>
<li><strong>空分复用</strong>(虚拟储存技术)<ul>
<li>物理4GB内存，用户看来远大于4GB</li>
</ul>
</li>
<li><strong>时分复用</strong>(虚拟处理器技术)<ul>
<li>一个CPU看上去是几个CPU,多个程序并发运行</li>
</ul>
</li>
</ul>
</li>
</ul>
<ol start="4">
<li><strong>异步</strong></li>
</ol>
<ul>
<li>异步是指,在多道程序环境下,允许多个程序并发执行,但由于资源有限,进程的执行不是一贯到底的,是走走停停（等待资源进程阻塞）,以不可预知的速度向前推异步性。</li>
</ul>
<h2 id="2-发展和分类"><a href="#2-发展和分类" class="headerlink" title="2. 发展和分类"></a>2. 发展和分类</h2><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/105010362.png" alt="mark"></p>
<ol>
<li><p><strong>手工操作阶段</strong>(IO靠纸带打孔，资源利用率低)</p>
</li>
<li><p><strong>批处理阶段</strong></p>
<ul>
<li><p>单道批处理系统<br>引入了脱机输入/输出技术（磁带），通过监督程序（操作系统雏形）控制作业输入输出</p>
<p>外围机负责把输入纸带录入磁带</p>
<p>缓解了人机速度矛盾，提高了资源利用率，但是CPU是串行的，大量CPU时间浪费在I/O等待上</p>
</li>
<li><p>多道批处理系统<br>磁带往内存输入多道程序，并发执行，输入、计算、输出互不干扰</p>
<p>操作系统诞生，引入了中断技术，资源利用率大幅上升，但是缺少人机交互功能，用户响应时间长（用户提交作业之后只能等待作业完成）</p>
</li>
</ul>
</li>
<li><p><strong>分时操作系统</strong></p>
<ul>
<li>分时操作系统：计算机以时间片为单位轮流为各个用户/作业服务,各个用户可通过终端与计算机进行交互。</li>
<li>主要优点:用户请求可以被即时响应,解决了人机交互问题。允许多个用户同时使用一台计算机,并且用户对计算机的操作相互独立,感受不到别人的存在。</li>
<li>主要缺点:不能优先处理一些紧急任务。操作系统对各个用户/作业都是完全公平的,循环地为每个用户/作业服务一个时间片,不区分任务的紧急性。</li>
</ul>
</li>
</ol>
<ol start="4">
<li><strong>网络操作系统</strong><ul>
<li>网络操作系统:是伴随着计算机网络的发展而诞生的,能把网络中各个计算机有机地结合起来,实现数据传送等功能,实现网络中各种资源的共享(如文件共享)和各台计算机之间的通信。(如: Windows NT就是一种典型的网络操作系统,网站服务器就可以使用)</li>
</ul>
</li>
</ol>
<ol start="5">
<li><strong>分布式操作系统</strong><ul>
<li>分布式操作系统:主要特点是分布性和并行性。系统中的各台计算机地位相同,任何工作都可以分布在这些计算机上,由它们并行、协同完成这个任务。</li>
</ul>
</li>
</ol>
<ol start="6">
<li><p><strong>PC操作系统</strong></p>
<ul>
<li><p>Windows10</p>
</li>
<li><p>MacOS</p>
</li>
<li><p>Ubuntu</p>
</li>
</ul>
</li>
</ol>
<p><strong>小结：发展历程</strong></p>
<p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/105106471.png" alt="mark"></p>
<h2 id="3-运行机制和体系结构"><a href="#3-运行机制和体系结构" class="headerlink" title="3. 运行机制和体系结构"></a>3. 运行机制和体系结构</h2><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/105349798.png" alt="mark"></p>
<h3 id="3-1-运行机制"><a href="#3-1-运行机制" class="headerlink" title="3.1 运行机制"></a>3.1 运行机制</h3><ul>
<li><p><strong>指令</strong></p>
<ul>
<li><p><strong>特权指令</strong></p>
<ul>
<li>内存清零指令</li>
</ul>
</li>
<li><p><strong>非特权指令</strong></p>
<ul>
<li>加减乘除运算指令</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li><p><strong>处理器状态</strong></p>
<ul>
<li><p><strong>核心态(目管态)</strong></p>
<ul>
<li>PSW=0，<strong>运行执行特权指令</strong><br>PSW 程序状态字寄存器，通过标志位标识处理器的运行状态</li>
</ul>
</li>
<li><p><strong>用户态(目态)</strong></p>
<ul>
<li>PSW=1，<strong>只能使用非特权指令</strong></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li><p><strong>程序</strong></p>
<ul>
<li><p><strong>应用程序</strong><br>为了安全，运行在用户态</p>
</li>
<li><p><strong>内核程序</strong><br>系统管理者，运行在核心态</p>
</li>
</ul>
</li>
</ul>
<h3 id="3-2-体系结构"><a href="#3-2-体系结构" class="headerlink" title="3.2 体系结构"></a>3.2 体系结构</h3><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/112129093.png" alt="mark"></p>
<ul>
<li><strong>大内核</strong><br>将操作系统的主要功能模块都作为系统内核，运行在核心态<br>高性能，但是内核代码庞大难以维护</li>
<li><strong>微内核</strong><br>只把基本概念保留在内核<br>功能少，功能清晰方便维护，但是需要频繁的在核心态和用户态之间切换，性能低</li>
</ul>
<h3 id="3-3-OS内核结构"><a href="#3-3-OS内核结构" class="headerlink" title="3.3 OS内核结构"></a>3.3 OS内核结构</h3><ul>
<li><p><strong>时钟管理</strong></p>
<ul>
<li>用于计时</li>
<li>通过时钟中断的管理,可以实现进程的切换</li>
</ul>
</li>
<li><p><strong>中断处理</strong></p>
</li>
<li><p><strong>原语</strong></p>
<ul>
<li>运行时间短，调用频繁，原子性运行只能一气呵成，不可中断</li>
</ul>
</li>
<li><p><strong>系统资源管理</strong></p>
<p>有的操作系统不把这个作为“内核功能”（微内核）</p>
<ul>
<li><p>进程管理</p>
</li>
<li><p>储存器管理</p>
</li>
<li><p>设备管理</p>
</li>
</ul>
</li>
</ul>
<h2 id="4-中断和异常"><a href="#4-中断和异常" class="headerlink" title="4. 中断和异常"></a>4. 中断和异常</h2><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/112855093.png" alt="mark"></p>
<h3 id="4-1-概念"><a href="#4-1-概念" class="headerlink" title="4.1 概念"></a>4.1 概念</h3><ul>
<li>发生了中断,就意味着需要操作系统介入,开展管理工作。 </li>
<li>由于操作系统的管理工作(比如进程切换、分配I/O设备等)需要<strong>使用特权指令</strong>,<strong>因此CPU要从用户态转为核心态</strong>。 </li>
<li>中断可以使CPU从用户态切换为核心态,使操作系统获得计算机的控制权。有了中断才能实现多道程序并发执行。 </li>
<li><strong>中断是CPU从用户态-&gt;核心态切换的唯一途径。</strong> </li>
<li><strong>核心态-&gt;用户态切换只需要执行一个特权指令</strong>，<code>将PSW设置为0</code></li>
</ul>
<h3 id="4-2-中断分类"><a href="#4-2-中断分类" class="headerlink" title="4.2 中断分类"></a>4.2 中断分类</h3><ul>
<li><p><strong>内中断(异常/例外/陷入)</strong></p>
<p><strong>信号来源CPU内部，与当前执行的指令有关</strong></p>
<ul>
<li><p>自愿中断(指令中断)<br>系统调用时使用的访管指令(陷入指令/trap指令)</p>
</li>
<li><p>强迫中断</p>
<ul>
<li><p>硬件故障<br>缺页错误</p>
</li>
<li><p>软件中断<br>除0错误</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>外中断(狭义中断)</strong></p>
<p><strong>信号来源CPU外部，与当前执行的指令无关</strong></p>
<ul>
<li><p>外设请求<br>外设(比如打印机)I/O操作完成发出中断信号<br>键盘输入一个字符</p>
</li>
<li><p>人工干预<br>用户强制终止一个进程</p>
</li>
</ul>
</li>
</ul>
<h3 id="4-3-中断处理的过程"><a href="#4-3-中断处理的过程" class="headerlink" title="4.3 中断处理的过程"></a>4.3 中断处理的过程</h3><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/114138459.png" alt="mark"></p>
<p><strong>大致处理过程</strong></p>
<ul>
<li>Step 1:执行完每个指令之后, CPU都要检查当前是否有外部中断信号 </li>
<li>Step 2:如果检测到外部中断信号,则需要保护被中断进程的CPU环境(如程序状态字Psw、程序计数器PC、各种通用寄存器) </li>
<li>Step 3:根据中断信号类型转入相应的中断处理程序(进入核心态) </li>
<li>Step 4:恢复原进程的CPU环境并退出中断,返回原进程继续往下执行</li>
</ul>
<h2 id="5-系统调用"><a href="#5-系统调用" class="headerlink" title="5. 系统调用"></a>5. 系统调用</h2><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/114523218.png" alt="mark"></p>
<h3 id="5-1-概念"><a href="#5-1-概念" class="headerlink" title="5.1 概念"></a>5.1 概念</h3><ul>
<li>“系统调用”是操作系统提供给应用程序(程序员/编程人员)使用的接口,可以理解为一种可供应用程序调用的特殊函数,应用程序可以<strong>发出系统调用请求来获得操作系统的服务</strong>。 </li>
<li>应用程序通过系统调用请求操作系统的服务。 系统中的各种共享资源都由操作系统统一掌管,因此在用户程序中,凡是与资源有关的操作(如存储分配、1/0操作、文件管理等) ,都必须通过系统调用的方式向操作系统提出服务请求,由操作系统代为完成。</li>
<li><strong>这样可以保证系统的稳定性和安全性,防止用户进行非法操作。</strong> </li>
<li><strong>系统调用相关的处理需要在核心态下完成。</strong></li>
</ul>
<h3 id="5-2-系统调用和库函数的区别"><a href="#5-2-系统调用和库函数的区别" class="headerlink" title="5.2 系统调用和库函数的区别"></a>5.2 系统调用和库函数的区别</h3><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/115154503.png" alt="mark"></p>
<h3 id="5-3-系统调用过程"><a href="#5-3-系统调用过程" class="headerlink" title="5.3 系统调用过程"></a>5.3 系统调用过程</h3><p><img src="http://zhuuu-bucket.oss-cn-beijing.aliyuncs.com/img/20201003/115353845.png" alt="mark"></p>
<p><strong>参考书籍：《王道考研计算机操作系统》</strong></p>
<p><strong>参考博客</strong> ： <a href="https://mubu.com/doc/Cd-Y4YOfkh#" target="_blank" rel="noopener">https://mubu.com/doc/Cd-Y4YOfkh#</a></p>
<p>​                    <a href="https://blog.csdn.net/weixin_43914604/article/details/104415990" target="_blank" rel="noopener">https://blog.csdn.net/weixin_43914604/article/details/104415990</a></p>

      
      <!-- reward -->
      
      <div id="reward-btn">
        打赏
      </div>
      
    </div>
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>版权声明： </strong s>
              本博客所有文章除特别声明外，均采用 <a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="external nofollow"
                target="_blank">Apache License 2.0</a> 许可协议。转载请注明出处！
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://zhuuu.work/2020/10/03/Linux/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F-01-%E6%A6%82%E8%BF%B0/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" rel="tag">操作系统</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/2020/10/03/Leetcode/Leetcode-976-%E4%B8%89%E8%A7%92%E5%BD%A2%E7%9A%84%E6%9C%80%E5%A4%A7%E5%91%A8%E9%95%BF/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Leetcode-977-有序数组的平方
          
        </div>
      </a>
    
    
      <a href="/2020/10/02/Leetcode/Leetcode-717-1%E6%AF%94%E7%89%B9%E4%B8%8E2%E6%AF%94%E7%89%B9%E5%AD%97%E7%AC%A6/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">Leetcode-717-1比特与2比特字符</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        notify: false,
        verify: '',
        app_id: '',
        app_key: '',
        path: window.location.pathname,
        avatar: 'mp',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
<div class="gitalk" id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1.5.0/dist/gitalk.css">


<script src="https://cdn.jsdelivr.net/npm/gitalk@1.5.0/dist/gitalk.min.js"></script>


<script src="https://cdn.jsdelivr.net/npm/blueimp-md5@2.10.0/js/md5.min.js"></script>

<script type="text/javascript">
  var gitalk = new Gitalk({
    clientID: 'db188ed8c86dc4b0dbf3',
    clientSecret: 'a58f92160e5a9efd726b7d533000a0737f3e3f3e',
    repo: 'Blog-comments',
    owner: 'Zhuuuuuuuu',
    admin: ['Zhuuuuuuuu'],
    // id: location.pathname,      // Ensure uniqueness and length less than 50
    id: md5(location.pathname),
    distractionFreeMode: false,  // Facebook-like distraction free mode
    pagerDirection: 'last'
  })

  gitalk.render('gitalk-container')
</script>

  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2019-2021
        Zhuuu
      </li>
      <li>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
    <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
      <aside class="sidebar">
        <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="朱酱酱的学习博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/JVM/">JVM</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/JDK%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90/">JDK源码</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/">多线程</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/Mysql/">Mysql</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/Redis/">Redis</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E8%AE%BE%E8%AE%A1%E8%80%85%E6%A8%A1%E5%BC%8F/">设计模式</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/MyBatis/">MyBatis</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/SpringMVC/">SpringMVC</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/Spring/">Spring</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/SpringBoot/">SpringBoot</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/">Linux</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/Leetcode/">Leetcode</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E5%89%8D%E7%AB%AF/">前端</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/">网络编程</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/photoshop/">photoshop</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="http://smartzhuuu.lofter.com/" target="_blank" rel="noopener">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2020/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
      </aside>
      <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
      
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<script src="/js/share.js"></script>



<script src="/fancybox/jquery.fancybox.min.js"></script>




<script>
  try {
    var typed = new Typed("#subtitle", {
    strings: ['昨夜西风凋碧树。独上高楼，望尽天涯路','衣带渐宽终不悔，为伊消得人憔悴。','众里寻他千百度。蓦然回首，那人却在，灯火阑珊处。'],
    startDelay: 0,
    typeSpeed: 200,
    loop: true,
    backSpeed: 100,
    showCursor: true
    });
  } catch (err) {
  }
  
</script>




<script src="/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer:'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
    onClick: (e) => {
      $('.toc-link').removeClass('is-active-link');
      $(`a[href=${e.target.hash}]`).addClass('is-active-link');
      $(e.target.hash).scrollIntoView();
      return false;
    }
  });
</script>


<script>
  var ayerConfig = {
    mathjax: true
  }
</script>


<script src="/js/ayer.js"></script>


<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>



<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>
  </div>
</body>

</html>